package dcl.software.filesync.server.config;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

//@EnableWebMvc
//@ControllerAdvice
public class ServiceExceptionHandler extends ResponseEntityExceptionHandler {
	// @ResponseStatus(value = HttpStatus.BAD_REQUEST)
	// @ExceptionHandler({ Exception.class })
	public HttpServletResponse badRequest(HttpServletResponse req, Exception exception) {
		try {
			req.sendError(HttpStatus.BAD_REQUEST.value(), exception.getMessage());
		} catch (IOException e) {
			throw new RuntimeException("Exception occurred in WorkProductTokenController.handleIOException: " + e.getMessage());
		}
		return req;
	}
}